package com.sxt.sys.controller;

import com.sxt.sys.constant.SYSConstant;
import com.sxt.sys.utils.ResultObj;
import com.sxt.sys.utils.WebUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author WanMing
 * @date 2019/2/2 21:34
 */

@Controller
@RequestMapping("logout")
public class LogoutController {


    @RequestMapping("logout")
    @ResponseBody
    public ResultObj logout(){
        ResultObj resultObj = null;
        try {
            WebUtils.getCurrentSession().removeAttribute("operator");
            resultObj = new ResultObj(SYSConstant.SUCCESS_CODE,SYSConstant.LOGOUT_SUCCESS);
        } catch (Exception e) {
            resultObj = new ResultObj(SYSConstant.ERROR_CODE,SYSConstant.LOGOUT_ERROR);
            e.printStackTrace();
        }

        return resultObj;
    }
}
